Hello, When I open an Excel file, I try to get the last save time of this file. Here is my code, which pops up the error with oleGet(objsavetime, "Value", date_file)
OleAutoObj objExcel = null
OleAutoObj objWorkbooks = null
OleAutoObj objWorkbook = null
OleAutoObj objDocProp = null
OleAutoObj objsavetime = null
OleAutoArgs args = create
bool validateFileName( string userFileName )
{
bool returnValue = true
if ( null userFileName ) returnValue = false
else
{
if ( !fileExists_ userFileName ) returnValue = false
}
return( returnValue )
}
objExcel = connectToApp(cObjExcelApplication, (NLS_("Excel")))
if (null objExcel) return false
makeVisible objExcel
checkRes(oleGet(objExcel,cPropertyWorkbooks,objWorkbooks))
if (null objWorkbooks) {
ack getExtMsg("String_Unable_to_get_workbooks_collection",NLSTEMP_("Unable to get workbooks collection"))
return false
}
string file_name = "MyFileEntirePath" //Enter an existing fullName excel file
string date_file = "null"
string prop_name = "null"
if(validateFileName (file_name))
{
clear( args )
put( args, "FileName", file_name )
checkRes( oleMethod( objWorkbooks, "Open", args, objWorkbook ) )
checkRes(oleGet(objExcel,cPropertyActiveWorkbook,objWorkbook))
checkRes(oleGet(objWorkbook,"BuiltinDocumentProperties", objDocProp))
if (objDocProp == null) print "KO"
clear (args)
put(args, 12) //last save time
checkRes(oleGet(objDocProp, "Item", args, objsavetime))
checkRes(oleGet(objsavetime, "Name", prop_name))
print prop_name "\n"
checkRes(oleGet(objsavetime, "Value", date_file))
print date_file "\n"
}
Can someone help me in that error ? Estebell - Wed Nov 23 04:15:09 EST 2016 |
Re: Get excel file properties The code looks good, can you get the "Type" property (integer) from the DocumentProperty to see, if it really returns (msoPropertyTypeString)? Maybe you simply need to use a different type for the result reference inside the oleGet (date? int?) Regards, Mathias |